﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace ado_test
{
    public partial class ModifyPasswd : Form
    {
        OleDbConnection conn = null;
        public string username;

        public ModifyPasswd()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = this.conn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "update users set [password]='" + this.textBox2.Text + "' where username='" + this.username + "'";
            //cmd.CommandText = "update uname set pwd='" + this.textBox2.Text + "' where uname='" + "test" + "'";
            MessageBox.Show(cmd.CommandText);
            int i = cmd.ExecuteNonQuery();

            if (i > 0)
            {
                MessageBox.Show("修改成功!");
            }

        }

        private void ModifyPasswd_Load(object sender, EventArgs e)
        {
            conn = new OleDbConnection();
            conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\\..\\student.accdb";

            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                //MessageBox.Show("已连接!");
                this.Text = "已连接!";
            }


        }
    }
}
